package com.lq.schoolshop.dao;

import com.lq.schoolshop.pojo.Expand.OrderAndOrderDetailAndStore;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author
 * @Date2021/1/13 11:48
 * @Version V1.0
 * 为什么努力？想把钱都赚够，一心跳广场舞曲去。
 **/
public interface PersonalCenterMapper {
    //查询订单全部信息
    @Select("SELECT  o.orderuuid AS orderuuid, o.price AS oprice,o.createtime AS createtime,o.address AS address,o.phone AS phone,o.payment AS payment,o.STATUS AS STATUS,o.deliverystatus AS deliverystatus,ors.id AS orsid ,ors.count AS orscount,ors.moneytotal AS moneytotal,g.id AS gid,g.name AS gname,g.count AS gcount,g.price AS gprice,g.image AS gimage,g.detail AS gdetail,s.id AS sid,s.name AS sname,s.icon AS sicon,s.backimage AS sbackimage,s.detail AS sdetail FROM orders o,orderdetail ors,goods g,store s WHERE o.orderuuid=ors.oid AND ors.gid=g.id AND g.storeid=s.id  AND  uid=#{uid} ORDER BY o.createtime DESC")
    List<OrderAndOrderDetailAndStore> selByAll(int uid);

    //查询订单未发货信息
    @Select("SELECT  o.orderuuid AS orderuuid, o.price AS oprice,o.createtime AS createtime,o.address AS address,o.phone AS phone,o.payment AS payment,o.STATUS AS STATUS,o.deliverystatus AS deliverystatus,ors.id AS orsid ,ors.count AS orscount,ors.moneytotal AS moneytotal,g.id AS gid,g.name AS gname,g.count AS gcount,g.price AS gprice,g.image AS gimage,g.detail AS gdetail,s.id AS sid,s.name AS sname,s.icon AS sicon,s.backimage AS sbackimage,s.detail AS sdetail FROM orders o,orderdetail ors,goods g,store s WHERE o.orderuuid=ors.oid AND ors.gid=g.id AND g.storeid=s.id  AND  uid=#{uid} AND o.deliverystatus='待发货' ORDER BY o.createtime DESC")
    List<OrderAndOrderDetailAndStore> selNotSentByAll(int uid);

    //查询已经发货信息
    @Select("SELECT  o.orderuuid AS orderuuid, o.price AS oprice,o.createtime AS createtime,o.address AS address,o.phone AS phone,o.payment AS payment,o.STATUS AS STATUS,o.deliverystatus AS deliverystatus,ors.id AS orsid ,ors.count AS orscount,ors.moneytotal AS moneytotal,g.id AS gid,g.name AS gname,g.count AS gcount,g.price AS gprice,g.image AS gimage,g.detail AS gdetail,s.id AS sid,s.name AS sname,s.icon AS sicon,s.backimage AS sbackimage,s.detail AS sdetail FROM orders o,orderdetail ors,goods g,store s WHERE o.orderuuid=ors.oid AND ors.gid=g.id AND g.storeid=s.id  AND  uid=#{uid} AND o.deliverystatus='已发货' ORDER BY o.createtime DESC")
    List<OrderAndOrderDetailAndStore> selSentByAll(int uid);

    //查询已经完成发货信息
    @Select("SELECT  o.orderuuid AS orderuuid, o.price AS oprice,o.createtime AS createtime,o.address AS address,o.phone AS phone,o.payment AS payment,o.STATUS AS STATUS,o.deliverystatus AS deliverystatus,ors.id AS orsid ,ors.count AS orscount,ors.moneytotal AS moneytotal,g.id AS gid,g.name AS gname,g.count AS gcount,g.price AS gprice,g.image AS gimage,g.detail AS gdetail,s.id AS sid,s.name AS sname,s.icon AS sicon,s.backimage AS sbackimage,s.detail AS sdetail FROM orders o,orderdetail ors,goods g,store s WHERE o.orderuuid=ors.oid AND ors.gid=g.id AND g.storeid=s.id  AND  uid=#{uid} AND o.deliverystatus='已完成' ORDER BY o.createtime DESC")
    List<OrderAndOrderDetailAndStore> selSuccessSentByAll(int uid);

    //查询某个用户订单待发货信息
    @Select("SELECT count(*) FROM orders WHERE deliverystatus='待发货' AND uid=#{uid}")
    int selByWaitSendGoods(int uid);

    //查询订单已发货信息
    @Select("SELECT count(*) FROM orders WHERE deliverystatus='已发货' AND uid=#{uid}")
    int selBySentGoods(int uid);

    //查询订单已完成信息
    @Select("SELECT count(*) FROM orders WHERE deliverystatus='已完成' AND uid=#{uid}")
    int selByFinish(int uid);

}
